package com.example.shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.shop.pojo.Goods;
import com.example.shop.pojo.GoodsDescriptionPicture;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodsDescriptionPictureMapper extends BaseMapper<GoodsDescriptionPicture> {



    @Select("select * from r_goods_description_picture where goods_id = #{goodsId}")
    List<GoodsDescriptionPicture> selectById(Long goodsId);


    @Select("select goods_description_picture from r_goods_description_picture where goods_id = #{goodsId}")
    List<String> selectPictureById(Long goodsId);

    @Select("select goods_description_picture from r_goods_description_picture where goods_id = #{goodsId} limit 0,1")
    String selectOnePictureById(Long goodsId);

    @Insert("<script>" +
            "insert r_goods_description_picture(goods_id,goods_description_picture) " +
            "VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
                "(${item.goodsId},#{item.goodsDescriptionPicture})" +
            "</foreach>" +
            "</script>")
    int batchInsert(@Param("list") List<GoodsDescriptionPicture> list);

    @Insert("<script>" +
            "insert r_goods_description_picture(goods_id,goods_description_picture) " +
            "VALUES " +
            "<foreach collection='list' item='descriptionPicture' separator=','>" +
            "(${goodsId},#{descriptionPicture})" +
            "</foreach>" +
            "</script>")
    int insertList(@Param("goodsId")long goodsId,@Param("list") List<String> list);
}
